import Cookies from 'js-cookie'

const TokenKey = 'unicom_mall3.0_eshop_token'
const CallbackKey = 'unicom_mall3.0_eshop_callback_token'
const UserTypeKey = 'unicom_mall3.0_eshop_user_type'
export function getToken() {
  return Cookies.get(TokenKey)
}
export function getCallbackUrl() {
  return Cookies.get(CallbackKey)
}
export function setCallbackUrl(callback) {
  Cookies.set(CallbackKey, callback)
}
export function setUserType(type) {
  return Cookies.set(UserTypeKey, type)
}
export function getUserType() {
  return Cookies.get(UserTypeKey)
}
export function setToken(token, callback) {
  if (callback) {
    Cookies.set(CallbackKey, callback)
  }
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
